<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>发布微生活</title>
		<meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=no">
		<meta name="keywords" content="" />
		<meta name="description" content="" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<link rel="stylesheet" href="css/news.css" />
		<link rel="stylesheet" href="css/style3.css" />
		<link rel="stylesheet" href="css/style4.css" />
		<link rel="stylesheet" type="text/css" href="css/style1.css">
		<link rel="stylesheet" type="text/css" href="css/style.css">
		<link rel="stylesheet" type="text/css" href="iconfont/iconfont.css">
		<script type="text/javascript" src="script/jquery-3.3.1.min.js"></script>
		<script type="text/javascript" src="script/bootstrap.min.js"></script>
		<link rel="stylesheet" href="css/mui.min.css">
		<script type="text/javascript" src="js/mui.js"></script>
		<link rel="stylesheet" type="text/css" href="css/feedback-page.css" />
		<script type="text/javascript" src="script/iconfont.js"></script>
		<link rel="stylesheet" href="css/index.css" />
		<link rel="stylesheet" href="css/brandmodel.css" />
		<script type="text/javascript" src="js/rem.js"></script>
		<script type="text/javascript" src="js/datatruck.js"></script>
		<style>
			input{
				font-size:12px;
			}
			.mui-card .mui-control-content {
				padding: 10px;
			}

			.dynamic_images {
				width: 100%;
			}

			.dynamic_images ul {
				margin: 0;
				padding: 10px;
			}

			.dynamic_images ul li {
				float: left;
				list-style: none;
				width: 75px;
			}

			.dynamic_images ul li img {
				width: 98%;
				height: 75px;
			}

			.mui-input-group .mui-input-row {
				height: 40px;
			}

			.mui-input-row {
				position: relative;
			}

			mui.min.css:5 .mui-input-row {
				clear: left;
				overflow: hidden;
			}

			h5 {
				margin: 5px 7px;
			}

			.mui-page-content {
				width: 100%;
				height: 100%;
				background-color: #efeff4;
			}

			.feedback p {
				padding: 10px 15px 0;
				font-size: 16px;
				margin-top: 0;
				margin-bottom: 10px;
				color: #000;
			}

			.feedback textarea {
				height: 160px;
				margin-bottom: 0 !important;
				padding-bottom: 0 !important;
			}

			.brand-box {
				position: absolute;
				top: 0px;
				filter: alpha(opacity=60);
				background-color: #777;
				z-index: 1002;
				left: 0px;
				opacity: 0.5;
				-moz-opacity: 0.5;
			}

			.brand {
				vertical-align: middle;
				/*text-align: center;*/
			}

			.form {
				padding-left: 10px;
			}

			.car_info {
				padding-left: 10px;
			}
		</style>
		<script type="text/javascript">
			//兼容火狐、IE8
			//显示遮罩层
			function showMask() {
				//$("#form_info").hide();   infoheader
				document.getElementById('form_info').style.display = 'none';
				document.getElementById('infoheader').style.display = 'none';
				console.log($(document).height());
				console.log($(document).width());
				$("#brand-box").show();
				$("#brand-box").css("height", $(document).height());
				$("#brand-box").css("width", $(document).width());
			}
			//隐藏遮罩层
			function hideMask() {
				//document.getElementById('brand-box').style.display='none';
				$("#brand-box").hide();
			}
		</script>

		<script>
			var picArr = new Array(); // 存储图片
			// 删除
			$(document).on('click', '#delete_pic', function(event) {
				var aa = $(this).parents(".pic_look").index();
				picArr.splice(aa, 1);
				$(this).parents(".pic_look").remove();
			});
			
			//delete_photo  删除
			$(document).on('click', '#delete_photo', function(event) {
				var aa = $(this).parents(".pic_look").index();
				picArr.splice(aa, 1);
				files.splice(aa, 1);
				$(this).parents(".pic_look").remove();
			});
		</script>

		<!--<script src="js/mui.js"></script>-->
		<script src="js/mui.picker.min.js"></script>
		<script src="js/mui.picker.js"></script>
		<script src='js/feedback.js'></script>
		<script src="js/app.js"></script>
		<script>
			var files = [];
			var files2 = [];
			(function($, doc) {
				mui.init({
					swipeBack: true //启用右滑关闭功能
				});

				document.addEventListener("plusready", plusReady, false);

				function plusReady() {
					var wv = plus.webview.currentWebview();
					document.getElementById("addnew").addEventListener("tap", function() {
					var num = $(".pic_look.col-md-1.col-xs-4").length;

//						document.getElementById("number").innerHTML = num;
						if(num >= 15) {
							alert("最多不超过15张");
							document.getElementById("input").disabled = "disabled";
							$("#chose_pic_btn").css("display", "none");
						} else {
							showActionSheet(); //拍照还是相册
						}

					});

					plus.nativeUI.closeWaiting();

				}
			}(mui, document));

			// 添加文件
			var index = 1;
			var newUrlAfterCompress;

			function appendFile(p) {
				files.push({
					path: p,
					name: "newfile_" + index
				});
				index++;
			}
			function appendFile2(p) {
				files2.push({
					path: p,
					name: "photo_" + index
				});
				index++;
			}
			// 产生一个随机数
			function getUid() {
				return Math.floor(Math.random() * 100000000 + 10000000).toString();
			}

			function galleryImgs() { // 从相册中选择图片
				plus.gallery.pick(function(e) {
					console.log("选择了" + e.files.length + "个图片");
					for(var i = 0; i < e.files.length; i++) {
						if(i < 9) {
							var _str = "<span class='pic_look col-md-1 col-xs-4' style='background-image: url(" + e.files[i] + ")'><em id='delete_pic'>-</em></span>";
							$('#chose_pic_btn').before(_str);
							var dstname = "_downloads/" + getUid() + ".jpg"; //设置压缩后图片的路径
							newUrlAfterCompress = compressImage(e.files[i], dstname);
							appendFile(dstname);
						}
					}
				}, function(e) {
					console.log("取消选择图片");
				}, {
					filter: "image", 
					multiple: true
				});
			}
			function galleryImgs2() { // 从相册中选择图片
				plus.gallery.pick(function(e) {
					console.log("选择了" + e.files.length + "个图片");
					for(var i = 0; i < e.files.length; i++) {
						if(i < 9) {
							var _str = "<span class='pic_look col-md-1 col-xs-4' style='background-image: url(" + e.files[i] + ")'><em id='delete_pic'>-</em></span>";
							$('#chose_pic_btn2').before(_str);
							var dstname = "_downloads/" + getUid() + ".jpg"; //设置压缩后图片的路径
							newUrlAfterCompress = compressImage(e.files[i], dstname);
							appendFile2(dstname);
						}
					}
				}, function(e) {
					console.log("取消选择图片");
				}, {
					filter: "image",
					multiple: true
				});
			}

			//压缩图片，这个比较变态的方法，无法return
			function compressImage(src, dstname) {
				plus.zip.compressImage({
						src: src,
						dst: dstname,
						overwrite: true,
						quality: 20
					},
					function(event) {
						return event.target;
					},
					function(error) {
						console.log(error);
						return src;
					});

			}

			function showActionSheet() {
				var bts = [{
					title: "拍照"
				}, {
					title: "从相册选择"
				}];
				plus.nativeUI.actionSheet({
						cancel: "取消",
						buttons: bts
					},
					function(e) {
						if(e.index == 1) {
							getImage();
						} else if(e.index == 2) {
							galleryImgs();
						}
					}
				);
			}
			function showActionSheet2() {
				var bts = [{
					title: "拍照"
				}, {
					title: "从相册选择"
				}];
				plus.nativeUI.actionSheet({
						cancel: "取消",
						buttons: bts
					},
					function(e) {
						if(e.index == 1) {
							getImage2();
						} else if(e.index == 2) {
							galleryImgs2();
						}
					}
				);
			}
			//拍照
			function getImage() {
				var cmr = plus.camera.getCamera();
				cmr.captureImage(function(p) {
					plus.io.resolveLocalFileSystemURL(p, function(entry) {
						var localurl = entry.toLocalURL(); //
						var _str = "<span class='pic_look col-md-1 col-xs-4' style='background-image: url(" + localurl + ")'><em id='delete_pic'>-</em></span>";
						$('#chose_pic_btn').before(_str);
						var dstname = "_downloads/" + getUid() + ".jpg"; //设置压缩后图片的路径
						newUrlAfterCompress = compressImage(localurl, dstname);
						appendFile(dstname);
					});
				});
			}
			function getImage2() {
				var cmr = plus.camera.getCamera();
				cmr.captureImage(function(p) {
					plus.io.resolveLocalFileSystemURL(p, function(entry) {
						var localurl = entry.toLocalURL(); //
						var _str = "<span class='pic_look col-md-1 col-xs-4' style='background-image: url(" + localurl + ")'><em id='delete_pic'>-</em></span>";
						$('#chose_pic_btn2').before(_str);
						var dstname = "_downloads/" + getUid() + ".jpg"; //设置压缩后图片的路径
						newUrlAfterCompress = compressImage(localurl, dstname);
						appendFile2(dstname);
					});
				});
			}
		</script>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav" id="infoheader" style="background-color: #00002E">
			<div class="mo-header-left">
				<a href="#">
					<font color="#F8F8F8">首页 </font>
				</a>
				<font color="#F8F8F8"> <i class="mui-icon iconfont icon-youdayu"></i></font>
				<a href="#">
					<font color="#F8F8F8"> 发布信息 </font>
				</a>
			</div>
		</header>

		<div class="mui-content" id="form_info">
			<div id="item" class="mui-control-content mui-active">
				<form id="form_info">
					<div class="upload_picture">
						<span>上传照片<!--(已选择</span>
						<span id="number">0</span>
						<span>/15)--></span>
					</div>

					<div class="release_up_pic">
						<div class="up_pic">
							<div id="chose_pic_btn" class="col-md-1 col-xs-4">
								<img src="images/true.jpg" id="addnew">
							</div>
						</div>
					</div>
					<div class="car_info">车辆信息</div>

					<!--<div class="form">
						<label class="form_control">品牌型号</label>
						<input type="text" id="brandmodel1" class="brand"/>
					</div>-->
					<div class="form1">
						<div id="container1">
							<div class="content1">
								<div class="left1">
									品牌型号：
								</div>
								<div class="right1">
									<input type="text" class="input1" id="address1" placeholder="请选择">
									<span class="next-icon1"> > </span>
								</div>
							</div>
						</div>
						<section id="mymodal1">
							<div class="modal-main1">
								<p class="address-title1">品牌型号</p>
								<p class="close1">x</p>
								<ul class="optionwrapper1">
									<li class="option-menu1 option-menu-one1 active-option1">请选择</li>
									<li class="option-menu1 option-menu-two1"></li>
									<li class="option-menu1 option-menu-three1"></li>
								</ul>
								<div class="option-content1">
									<ul class="option-group1 option-group-one1" data-index1="0" style="display: block">
									</ul>
									<ul class="option-group1 option-group-two1" data-index1="1">
									</ul>
									<ul class="option-group1 option-group-three1"  data-index1="2">
									</ul>
								</div>
							</div>
						</section>
					</div>
					<!--<div class="form">
						<label class="form_control">所在地区</label>
						<input type="text" id="city1" class="brand"/>
					</div>-->
					<div class="form">
						<li class="lis">
						    <section class="express-area">
						        <a id="expressArea1" href="javascript:void(0)">
						            <div>
						                <!--<dt>所在城市</dt>
						                <dd class="city">省 市</dd>-->
						                <span>所在城市</span>
						                <input type="text" class="city1" placeholder="省 市" style="width:50%;">
						            </div>
						        </a>

						    </section>
						    <!--选择地区弹层-->
						    <section id="areaLayer1" class="express-area-box">
						        <article id="areaBox1">
						        	<ul class="remen" id="remen1">
						        		<li class="lastli">热门城市</li>
						        		<li class="list1">北京</li>
						        		<li class="list1">上海</li>
						        		<li class="list1">广州</li>
						        		<li class="list1">深圳</li>
						        		<li class="list1">天津</li>
						        		<li class="list1">重庆</li>
						        	</ul>
						        	<div class="top">
							            <h3>选择城市</h3>
							        </div>
						            <ul id="areaList1" class="area-list" style="margin-bottom: 500px;"></ul>
						        </article>
						    </section>
						    <!--遮罩层-->
						    <div id="areaMask1" class="mask"></div>
						</li>
					</div>

					<!--<div class="list">
						<label class="time">出厂年限</label>
						<input id="select_5" />
					</div>-->

					<div class="form">
						<label class="form_control">上牌日期</label>
						<input type="text" id="registrationdate1" onclick="selectdate5()" placeholder="选择日期..." class="brand" />
					</div>

					<div class="form">
						<label class="form_control">行驶里程(万公里)</label>
						<input type="text" id="mileage1" class="brand"/>

					</div>

					<div class="form">
						<label class="form_control">马力(匹)</label>
						<input type="text" id="horsepower1" class="brand"/>
					</div>

					<div class="form">
						<label class="form_control">整车重量(吨)</label>
						<input type="text" id="weight1" class="brand"/>
					</div>

					<div class="form">
						<label class="form_control">额定载重(吨)</label>
						<input type="text" id="ratedload1" class="brand"/>
					</div>

					<div class="form">
						<label class="form_control">货箱长度(米)</label>
						<input type="text" id="containerlength1" class="brand"/>
					</div>


					<div class="form">
						<label class="form_control">货箱宽度(米)</label>
						<input type="text" id="containerwidth1" class="brand"/>
                   </div>

					<div class="form">
						<label class="form_control">货箱高度(米)</label>
						<input type="text" id="containerheight1" class="brand"/>
					</div>

					<div class="form">
						<label class="form_control">报价(万)</label>
						<input type="text" id="wholesaleprice1" class="brand"/>
					</div>

					<div class="form">
						<label class="form_control">VIP底价(万)</label>
						<input type="text" id="vipfloorprice1" class="brand"/>
					</div>

					<div class="vip">VIP会员享受VIP底价</div>

					<div class="form">
						<div class="car_desc">车况描述</div>
						<textarea class="desc" id="description1"></textarea>
					</div>
					<input id="truckid" type="hidden"/>
					<div>
						<input type="button" onclick="uploadtruck()" value="立即发布" style="height:50px;width:100%;background-color:#007AFF;color:#6c6c6c;">
					</div>
				</form>
			</div>
			<script type="text/javascript" src="js/jquery.area.js" ></script>
		</div>




		<script>
			//选择上牌时间
			function selectdate() {
				var dDate = new Date();
				var year = dDate.getFullYear();
				var month = dDate.getMonth() + 1;
				var strDate = dDate.getDate();
				//dDate.setFullYear(year, month, strDate);
				var minDate = new Date();
				minDate.setFullYear(2000, 0, 1);
				var maxDate = new Date();
				maxDate.setFullYear(2100, 11, 31);
				mui.plusReady(function() {
					plus.nativeUI.pickDate(function(e) {
						var d = e.date;
						$('#registrationdate').val(d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate());
					}, function(e) {}, {
						title: "请选择日期",
						date: dDate,
						minDate: minDate,
						maxDate: maxDate
					});
				});
			}

			//选择年检到期时间
			function selectdate1() {
				var dDate = new Date();
				var year = dDate.getFullYear();
				var month = dDate.getMonth() + 1;
				var strDate = dDate.getDate();
				//dDate.setFullYear(year, month, strDate);
				var minDate = new Date();
				minDate.setFullYear(2000, 0, 1);
				var maxDate = new Date();
				maxDate.setFullYear(2100, 11, 31);
				mui.plusReady(function() {
					plus.nativeUI.pickDate(function(e) {
						var d = e.date;
						$('#yearinsurance').val(d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate());
					}, function(e) {}, {
						title: "请选择日期",
						date: dDate,
						minDate: minDate,
						maxDate: maxDate
					});
				});
			}

			//选择商业险到期时间
			function selectdate2() {
				var dDate = new Date();
				var year = dDate.getFullYear();
				var month = dDate.getMonth() + 1;
				var strDate = dDate.getDate();
				//dDate.setFullYear(year, month, strDate);
				var minDate = new Date();
				minDate.setFullYear(2000, 0, 1);
				var maxDate = new Date();
				maxDate.setFullYear(2100, 11, 31);
				mui.plusReady(function() {
					plus.nativeUI.pickDate(function(e) {
						var d = e.date;
						$('#commercialinsurance').val(d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate());
					}, function(e) {}, {
						title: "请选择日期",
						date: dDate,
						minDate: minDate,
						maxDate: maxDate
					});
				});
			}

			//选择交强险到期时间
			function selectdate3() {
				var dDate = new Date();
				var year = dDate.getFullYear();
				var month = dDate.getMonth() + 1;
				var strDate = dDate.getDate();
				//dDate.setFullYear(year, month, strDate);
				var minDate = new Date();
				minDate.setFullYear(2000, 0, 1);
				var maxDate = new Date();
				maxDate.setFullYear(2100, 11, 31);
				mui.plusReady(function() {
					plus.nativeUI.pickDate(function(e) {
						var d = e.date;
						$('#compulsoryinsurance').val(d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate());
					}, function(e) {}, {
						title: "请选择日期",
						date: dDate,
						minDate: minDate,
						maxDate: maxDate
					});
				});
			}


			//货车选择上牌时间   registrationdate1
			function selectdate5() {
				var dDate = new Date();
				var year = dDate.getFullYear();
				var month = dDate.getMonth() + 1;
				var strDate = dDate.getDate();
				//dDate.setFullYear(year, month, strDate);
				var minDate = new Date();
				minDate.setFullYear(2000, 0, 1);
				var maxDate = new Date();
				maxDate.setFullYear(2100, 11, 31);
				mui.plusReady(function() {
					plus.nativeUI.pickDate(function(e) {
						var d = e.date;
						$('#registrationdate1').val(d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate());
					}, function(e) {}, {
						title: "请选择日期",
						date: dDate,
						minDate: minDate,
						maxDate: maxDate
					});
				});
			}

			// 上传文件
			(function($, doc) {
				console.log("join...");
				$.init();

				var id = "";
				//$('#vipfloorprice').hide();
				$.plusReady(function() {
					var self = plus.webview.currentWebview();
					//获取前面页中的extras中的参数
					id = self.ids;
//					$('#id').val(id);
					document.getElementById('truckid').value = id;
					var url = servicePath+"sechandcar/app/sys/selectTruckInfo";
					mui.ajax(url, {
						data: {
							id: id
						}, //把json转换为字符串
						dataType: 'json', //返回数据格式
						type: 'get', //请求方式
						async: false,
						success: back0
					});

				});

			}(mui, document));

			function back0(data) {


				if(data[0].brandmodel != null && data[0].brandmodel != '') {
					$('#address1').val(data[0].brandmodel);
				}
				if(data[0].city != null && data[0].city != '') {
					$('.city1').val(data[0].city);
				}
				if(data[0].registrationdate != null && data[0].registrationdate != '') {
					$('#registrationdate1').val(data[0].registrationdate);
				}
				if(data[0].mileage != null && data[0].mileage != '') {
					$('#mileage1').val(data[0].mileage);
				}
				if(data[0].horsepower != null && data[0].horsepower != '') {
					$('#horsepower1').val(data[0].horsepower);
				}
				if(data[0].weight != null && data[0].weight != '') {
					$('#weight1').val(data[0].weight);
				}
				if(data[0].ratedload != null && data[0].ratedload != '') {
					$('#ratedload1').val(data[0].ratedload);
				}
				if(data[0].containerlength != null && data[0].containerlength != '') {
					$('#containerlength1').val(data[0].containerlength);
				}
				if(data[0].containerwidth != null && data[0].containerwidth != '') {
					$('#containerwidth1').val(data[0].containerwidth);
				}
				if(data[0].containerheight != null && data[0].containerheight != '') {
					$('#containerheight1').val(data[0].containerheight);
				}
				if(data[0].wholesaleprice != null && data[0].wholesaleprice != '') {
					$('#wholesaleprice1').val(data[0].wholesaleprice);
				}
				if(data[0].vipfloorprice != null && data[0].vipfloorprice != '') {
					$('#vipfloorprice1').val(data[0].vipfloorprice);
				}
				//wholesaleprice
				if(data[0].description != null && data[0].description != '') {
					$('#description1').val(data[0].description);
				}

				if(data[0].photo1 != null && data[0].photo1 != '') {
					$('#photo1').val(data[0].photo1);
					var _str = "<span class='pic_look col-md-1 col-xs-4' style='background-image: url(" + servicePath+data[0].photo1 + ")'><em id='delete_photo'>-</em></span>";
					$('#chose_pic_btn').before(_str);
					files.push({
						path: data[0].photo1,
						name: "photo_1"
					});
				}
				if(data[0].photo2 != null && data[0].photo2 != '') {
					$('#photo2').val(data[0].photo2);
					var _str = "<span class='pic_look col-md-1 col-xs-4' style='background-image: url(" + servicePath+data[0].photo2 + ")'><em id='delete_photo'>-</em></span>";
					$('#chose_pic_btn').before(_str);
					files.push({
						path: data[0].photo2,
						name: "photo_2"
					});
				}
				if(data[0].photo3 != null && data[0].photo3 != '') {
					$('#photo3').val(data[0].photo3);
					var _str = "<span class='pic_look col-md-1 col-xs-4' style='background-image: url(" + servicePath+data[0].photo3 + ")'><em id='delete_photo'>-</em></span>";
					$('#chose_pic_btn').before(_str);
					files.push({
						path: data[0].photo3,
						name: "photo_3"
					});
				}
				if(data[0].photo4 != null && data[0].photo4 != '') {
					$('#photo4').val(data[0].photo4);
					var _str = "<span class='pic_look col-md-1 col-xs-4' style='background-image: url(" + servicePath+data[0].photo4 + ")'><em id='delete_photo'>-</em></span>";
					$('#chose_pic_btn').before(_str);
					files.push({
						path: data[0].photo4,
						name: "photo_4"
					});
				}
				if(data[0].photo5!= null && data[0].photo5 != '') {
					$('#photo5').val(data[0].photo5);
					var _str = "<span class='pic_look col-md-1 col-xs-4' style='background-image: url(" + servicePath+data[0].photo5 + ")'><em id='delete_photo'>-</em></span>";
					$('#chose_pic_btn').before(_str);
					files.push({
						path: data[0].photo5,
						name: "photo_5"
					});
				}
				if(data[0].photo6 != null && data[0].photo6 != '') {
					$('#photo6').val(data[0].photo6);
					var _str = "<span class='pic_look col-md-1 col-xs-4' style='background-image: url(" + servicePath+data[0].photo6 + ")'><em id='delete_photo'>-</em></span>";
					$('#chose_pic_btn').before(_str);
					files.push({
						path: data[0].photo6,
						name: "photo_6"
					});
				}
				if(data[0].photo7 != null && data[0].photo7 != '') {
					$('#photo7').val(data[0].photo7);
					var _str = "<span class='pic_look col-md-1 col-xs-4' style='background-image: url(" + servicePath+data[0].photo7 + ")'><em id='delete_photo'>-</em></span>";
					$('#chose_pic_btn').before(_str);
					files.push({
						path: data[0].photo7,
						name: "photo_7"
					});
				}
				if(data[0].photo8 != null && data[0].photo8 != '') {
					$('#photo8').val(data[0].photo8);
					var _str = "<span class='pic_look col-md-1 col-xs-4' style='background-image: url(" + servicePath+data[0].photo8 + ")'><em id='delete_photo'>-</em></span>";
					$('#chose_pic_btn').before(_str);
					files.push({
						path: data[0].photo8,
						name: "photo_8"
					});
				}
				if(data[0].photo9 != null && data[0].photo9 != '') {
					$('#photo9').val(data[0].photo9);
					var _str = "<span class='pic_look col-md-1 col-xs-4' style='background-image: url(" + servicePath+data[0].photo9 + ")'><em id='delete_photo'>-</em></span>";
					$('#chose_pic_btn').before(_str);
					files.push({
						path: data[0].photo9,
						name: "photo_9"
					});
				}
				if(data[0].photo10 != null && data[0].photo10 != '') {
					$('#photo10').val(data[0].photo10);
					var _str = "<span class='pic_look col-md-1 col-xs-4' style='background-image: url(" + servicePath+data[0].photo10 + ")'><em id='delete_photo'>-</em></span>";
					$('#chose_pic_btn').before(_str);
					files.push({
						path: data[0].photo10,
						name: "photo_10"
					});
				}
				if(data[0].photo11 != null && data[0].photo11 != '') {
					$('#photo11').val(data[0].photo11);
					var _str = "<span class='pic_look col-md-1 col-xs-4' style='background-image: url(" + servicePath+data[0].photo11 + ")'><em id='delete_photo'>-</em></span>";
					$('#chose_pic_btn').before(_str);
					files.push({
						path: data[0].photo11,
						name: "photo_11"
					});
				}
				if(data[0].photo12 != null && data[0].photo12 != '') {
					$('#photo12').val(data[0].photo12);
					var _str = "<span class='pic_look col-md-1 col-xs-4' style='background-image: url(" + servicePath+data[0].photo12 + ")'><em id='delete_photo'>-</em></span>";
					$('#chose_pic_btn').before(_str);
					files.push({
						path: data[0].photo12,
						name: "photo_12"
					});
				}
				if(data[0].photo13 != null && data[0].photo13 != '') {
					$('#photo13').val(data[0].photo13);
					var _str = "<span class='pic_look col-md-1 col-xs-4' style='background-image: url(" + servicePath+data[0].photo13 + ")'><em id='delete_photo'>-</em></span>";
					$('#chose_pic_btn').before(_str);
					files.push({
						path: data[0].photo13,
						name: "photo_13"
					});
				}
				if(data[0].photo14 != null && data[0].photo14 != '') {
					$('#photo14').val(data[0].photo14);
					var _str = "<span class='pic_look col-md-1 col-xs-4' style='background-image: url(" + servicePath+data[0].photo14 + ")'><em id='delete_photo'>-</em></span>";
					$('#chose_pic_btn').before(_str);
					files.push({
						path: data[0].photo14,
						name: "photo_14"
					});
				}
				if(data[0].photo15 != null && data[0].photo15 != '') {
					$('#photo15').val(data[0].photo15);
					var _str = "<span class='pic_look col-md-1 col-xs-4' style='background-image: url(" + servicePath+data[0].photo15 + ")'><em id='delete_photo'>-</em></span>";
					$('#chose_pic_btn').before(_str);
					files.push({
						path: data[0].photo15,
						name: "photo_15"
					});
				}
				if(data[0].status != null && data[0].status != '') {
					$('#status').val(data[0].status);
				}
				if(data[0].telephone != null && data[0].telephone != '') {
					$('#telephone').val(data[0].telephone);
				}
				if(data.clicksum != null && data.clicksum != '') {
					$('#clicksum').val(data.clicksum);
				}

			}


			function uploadtruck() {

				var task = plus.uploader.createUpload(servicePath+'sechandcar/app/sys/updatesavetruck', {
						method: "POST"
				},  
					function(t, status) { //上传完成
						if(status == 200) {
							if(t.responseText == 'success') {
								alert('修改成功');
//								$('#fabu').hide(); 
								mui.back();
//								window.history.go(-1);
							} else {
								alert('修改失败');
								mui.back();
							}

						} else {
							console.log("修改失败：" + status);
							mui.back();
						}
					}
				);
				
				
				for(var i = 0; i < files.length; i++) {
					var f = files[i];
					if(f.name.indexOf("newfile")!=-1){
						task.addFile(f.path, {
						key: "photo_"+(i+1)
						});
					}else{
//						alert(f.path);
						task.addData("photo"+(i+1), f.path);
					}
					

				}

				/*for(var i = 0; i < files.length; i++) {
					var f = files[i];
					task.addFile(f.path, {
						key: f.name
					});

				}*/
				var brandmodel = $('#address1').val();
				var city = $('.city1').val();
				var registrationdate = $('#registrationdate1').val();
				var mileage = $('#mileage1').val();
				var horsepower = $('#horsepower1').val();
				var weight = $('#weight1').val();
				var ratedload = $('#ratedload1').val();
				var containerlength = $('#containerlength1').val();
				var containerwidth = $('#containerwidth1').val();
				var containerheight = $('#containerheight1').val();
				var wholesaleprice = $('#wholesaleprice1').val();
				var vipfloorprice = $('#vipfloorprice1').val();
				var description = $('#description1').val();
				var tel = window.localStorage.getItem("telephone");
			    var nickname = window.localStorage.getItem("nickname");
			    var adduserid = window.localStorage.getItem("id");

				var photo1 = $('#photo1').val();
				var photo2 = $('#photo2').val();
				var photo3 = $('#photo3').val();
				var photo4 = $('#photo4').val();
				var photo5 = $('#photo5').val();
				var photo6 = $('#photo6').val();
				var photo7 = $('#photo7').val();
				var photo8 = $('#photo8').val();
				var photo9 = $('#photo9').val();
				var photo10 = $('#photo10').val();
				var photo11 = $('#photo11').val();
				var photo12 = $('#photo12').val();
				var photo13 = $('#photo13').val();
				var photo14 = $('#photo14').val();
				var photo15 = $('#photo15').val();
				var idss = document.getElementById('truckid').value;
				task.addData('telephone',tel);
				task.addData('nickname', nickname);
				task.addData('adduserid', adduserid);
				var clicksum = $('#clicksum').val();
				task.addData('clicksum', clicksum);
				task.addData('status', status);

				task.addData('photo1', photo1);
				task.addData('photo2', photo2);
				task.addData('photo3', photo3);
				task.addData('photo4', photo4);
				task.addData('photo5', photo5);
				task.addData('photo6', photo6);
				task.addData('photo7', photo7);
				task.addData('photo8', photo8);
				task.addData('photo9', photo9);
				task.addData('photo10', photo10);
				task.addData('photo11', photo11);
				task.addData('photo12', photo12);
				task.addData('photo13', photo13);
				task.addData('photo14', photo14);
				task.addData('photo15', photo15);


				task.addData('brandmodel', brandmodel);
				task.addData('city', city);
				task.addData('registrationdate', registrationdate);
				task.addData('mileage', mileage);
				task.addData('horsepower', horsepower);
				task.addData('weight', weight);
				task.addData('ratedload', ratedload);
				task.addData('containerlength', containerlength);
				task.addData('containerwidth', containerwidth);
				task.addData('containerheight', containerheight);
				task.addData('wholesaleprice', wholesaleprice);

				task.addData('vipfloorprice', vipfloorprice);
				task.addData('id', idss);
				task.addData('description', description);
				task.start();

			}

			//选择车辆类型
			function selecttype(typename,index) {
				$('#cartype').val(typename);
				$(".form .cartp .form_li").removeClass("active");
				$(".form .cartp .form_li").eq(index).addClass("active");
			}

			//选择品牌型号
			function selectbrand(value, imgurl) {
				$("#brand-box").hide();
				document.getElementById('form_info').style.display = 'block';
				document.getElementById('infoheader').style.display = 'block';
				$('#brandmodel').val(value);
			}

			//选择变速箱
			function selecttransmission(transmission, index) {
				$('#transmission').val(transmission);
				$(".form .transm .form_li").removeClass("active");
				$(".form .transm .form_li").eq(index).addClass("active");
			}

			//选择车身颜色
			function selectcolor(id, colorname) {
				$('#colornames').empty();
				$('#colornames').html(colorname);

			}

			//选择排放标准
			function selectpaifang(paifang, index) {
				$('#paifang').val(paifang);
				$(".form .output .form_li").removeClass("active");
				$(".form .output .form_li").eq(index).addClass("active");
			}

			//选择燃油标准
			function selectranyou(ranyou, index) {
				$('#fueltype').val(ranyou);
				$(".form .fuel .form_li").removeClass("active");
				$(".form .fuel .form_li").eq(index).addClass("active");
			}
		</script>
		<script type="text/javascript">
			$(document).ready(function() {
				var newData = [];//新数据
				var citysArray = [];//城市
				var areaArray = [];//地区
				var chooseMenuStr = '请选择' //添加选择title

				var newData1 = [];//新数据
				var citysArray1 = [];//城市
				var areaArray1 = [];//地区
				var chooseMenuStr1 = '请选择' //添加选择title



				function init(){
					//模拟ajax
					setTimeout(()=>{
						newData = [...datatruck];
						// 初始化省份
						var optionGroupOne = "";
						$.each(newData,function(index, el) {
							optionGroupOne += `<li class="option-list option-list-one">
										<span>${newData[index]["n"]}</span>
										<div class="checked">
										</div>
									</li>`
						});

						$(".option-group-one").html(optionGroupOne)

					},100)
				}
				function init1(){
					//模拟ajax
					setTimeout(()=>{
						newData1 = [...datatruck];
						// 初始化省份
						var optionGroupOne1 = "";
						$.each(newData1,function(index, el) {
							optionGroupOne1 += `<li class="option-list1 option-list-one1">
										<span>${newData1[index]["n"]}</span>
										<div class="checked">
										</div>
									</li>`
						});

						$(".option-group-one1").html(optionGroupOne1)

					},100)
				}

				init();
				init1();


				$("#mymodal").on("click",".option-menu",function(){ //菜单激活
					var i = $(this).index();
					$(this).addClass('active-option').siblings().removeClass('active-option');
					$(".option-group").eq(i).show().siblings().hide()
				})
				$("#mymodal1").on("click",".option-menu1",function(){ //菜单激活
					var i1 = $(this).index();
					$(this).addClass('active-option').siblings().removeClass('active-option');
					$(".option-group1").eq(i1).show().siblings().hide()
				})

				//1级 省份点击添加城市
				$("#mymodal").on("click",".option-list-one",function(){
					var parentIndex = $(this).parent().attr("data-index");
					var provinceName = $(this).text().trim();
					var provinceIndex = $(this).index();
					$(this).find('.checked').show();
					$(this).siblings().find('.checked').hide();
					// console.log(newData[provinceIndex])
					citysArray = newData[provinceIndex]["c"];
					$(".option-menu").eq(parentIndex).text(provinceName)
					var cityStr = "";
					// console.log(citysArray)
					$.each(citysArray,function(index, el) {
						cityStr += `<li class="option-list option-list-two">
								<span>${citysArray[index]["n"]}</span>
								<div class="checked">
								</div>
							</li>`
					});
					// console.log(cityStr)
					$(".option-group").hide();
					$(".optionwrapper").find(".option-menu").removeClass('active-option')
					$(".option-menu-two").html(chooseMenuStr).addClass('active-option')
					$(".option-group-two").html(cityStr).show();
					$(".option-group-three").html("");
					$(".option-menu-three").html("")
				})

				$("#mymodal1").on("click",".option-list-one1",function(){
					var parentIndex1 = $(this).parent().attr("data-index1");
					var provinceName1 = $(this).text().trim();
					var provinceIndex1 = $(this).index();
					$(this).find('.checked').show();
					$(this).siblings().find('.checked').hide();
					// console.log(newData1[provinceIndex1])
					citysArray1 = newData1[provinceIndex1]["c"];
					$(".option-menu1").eq(parentIndex1).text(provinceName1)
					var cityStr1 = "";
					// console.log(citysArray1)
					$.each(citysArray1,function(index, el) {
						cityStr1 += `<li class="option-list1 option-list-two1">
								<span>${citysArray1[index]["n"]}</span>
								<div class="checked">
								</div>
							</li>`
					});
					// console.log(cityStr)
					$(".option-group1").hide();
					$(".optionwrapper1").find(".option-menu1").removeClass('active-option')
					$(".option-menu-two1").html(chooseMenuStr1).addClass('active-option')
					$(".option-group-two1").html(cityStr1).show();
					$(".option-group-three1").html("");
					$(".option-menu-three1").html("")
				})


				//2级 城市点击添加城镇
				$("#mymodal").on("click",".option-list-two",function(){
					var parentIndex = $(this).parent().attr("data-index");
					var cityName = $(this).text().trim();
					var cityIndex = $(this).index();
					$(this).find('.checked').show();
					$(this).siblings().find('.checked').hide();
					cityArray = citysArray[cityIndex]["a"];
					$(".option-menu").eq(parentIndex).text(cityName)
					var areaStr = "";
					$.each(cityArray,function(index, el) {
						areaStr += `<li class="option-list option-list-three">
								<span>${cityArray[index]}</span>
								<div class="checked">
								</div>
							</li>`
					});
					$(".option-group").hide();
					$(".optionwrapper").find(".option-menu").removeClass('active-option')
					$(".option-menu-three").html(chooseMenuStr).addClass('active-option')
					$(".option-group-three").html(areaStr).show();
				})
				$("#mymodal1").on("click",".option-list-two1",function(){
					var parentIndex1 = $(this).parent().attr("data-index1");
					var cityName1 = $(this).text().trim();
					var cityIndex1 = $(this).index();
					$(this).find('.checked').show();
					$(this).siblings().find('.checked').hide();
					cityArray1 = citysArray1[cityIndex1]["a"];
					$(".option-menu1").eq(parentIndex1).text(cityName1)
					var areaStr1 = "";
					$.each(cityArray1,function(index, el) {
						areaStr1 += `<li class="option-list1 option-list-three1">
								<span>${cityArray1[index]}</span>
								<div class="checked">
								</div>
							</li>`
					});
					$(".option-group1").hide();
					$(".optionwrapper1").find(".option-menu1").removeClass('active-option')
					$(".option-menu-three1").html(chooseMenuStr1).addClass('active-option')
					$(".option-group-three1").html(areaStr1).show();
				})
				//3级 选择城镇
				$("#mymodal").on("click",".option-list-three",function(){
					var areaName = $(this).text().trim();
					var parentIndex = $(this).parent().attr("data-index");
					var menuOne = $(".option-menu").eq(0).text();
					var menuTwo = $(".option-menu").eq(1).text();
					var addressVal = menuOne +" "+ menuTwo +" "+ areaName;
					$(this).find('.checked').show();
					$(this).siblings().find('.checked').hide();
					$(".option-menu").eq(parentIndex).text(areaName)
					$(".modal-main").animate({"bottom":"-900px"}, 400);
					setTimeout(()=>{
						$("#mymodal").fadeOut()
					},350)
					$("#address").val(addressVal)
				})
				$("#mymodal1").on("click",".option-list-three1",function(){
					var areaName1 = $(this).text().trim();
					var parentIndex1 = $(this).parent().attr("data-index1");
					var menuOne1 = $(".option-menu1").eq(0).text();
					var menuTwo1 = $(".option-menu1").eq(1).text();
					var addressVal1 = menuOne1 +" "+ menuTwo1 +" "+ areaName1;
					$(this).find('.checked').show();
					$(this).siblings().find('.checked').hide();
					$(".option-menu1").eq(parentIndex1).text(areaName1)
					$(".modal-main1").animate({"bottom":"-900px"}, 400);
					setTimeout(()=>{
						$("#mymodal1").fadeOut()
					},350)
					$("#address1").val(addressVal1)
				})

				$(".right").on("click",function(){
					$("#mymodal").show();
					$(".modal-main").animate({"bottom":"0"}, 400)
				})

				$(".right1").on("click",function(){
					$("#mymodal1").show();
					$(".modal-main1").animate({"bottom":"0"}, 400)
				})


				$(".close").on("click",function(){
					$(".modal-main").animate({"bottom":"-900px"}, 400);
					setTimeout(()=>{
						$("#mymodal").fadeOut();
					},350)
				})

				$(".close1").on("click",function(){
					$(".modal-main1").animate({"bottom":"-900px"}, 400);
					setTimeout(()=>{
						$("#mymodal1").fadeOut();
					},350)
				})

				$("#mymodal").on("click",function(event){
					var modalMain = $(".modal-main");
					if (!modalMain.is(event.target)&& modalMain.has(event.target).length === 0) {
						$(".modal-main").animate({"bottom":"-900px"}, 400);
						setTimeout(()=>{
							$("#mymodal").fadeOut();
						},350)
					}

				})
				$("#mymodal1").on("click",function(event){
					var modalMain1 = $(".modal-main1");
					if (!modalMain1.is(event.target)&& modalMain1.has(event.target).length === 0) {
						$(".modal-main1").animate({"bottom":"-900px"}, 400);
						setTimeout(()=>{
							$("#mymodal1").fadeOut();
						},350)
					}

				})
			});
		</script>
	</body>

</html>
